home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / gfx / nsIFontMetrics.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  8KB  |  242 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  26.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. #ifndef nsIFontMetrics_h___
  39. #define nsIFontMetrics_h___
  40.  
  41. #include "nsISupports.h"
  42. #include "nsCoord.h"
  43. #include "nsFont.h"
  44.  
  45. class nsString;
  46. class nsIDeviceContext;
  47. class nsIAtom;
  48.  
  49. // IID for the nsIFontMetrics interface
  50. #define NS_IFONT_METRICS_IID   \
  51. { 0xc74cb770, 0xa33e, 0x11d1, \
  52. { 0xa8, 0x24, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
  53.  
  54. //----------------------------------------------------------------------
  55.  
  56. /**
  57.  * A native font handle
  58.  */
  59. typedef void* nsFontHandle;
  60.  
  61. /**
  62.  * Font metrics interface
  63.  *
  64.  * This interface may be somewhat misnamed. A better name might be
  65.  * nsIFontList. The style system uses the nsFont struct for various font
  66.  * properties, one of which is font-family, which can contain a *list* of
  67.  * font names. The nsFont struct is "realized" by asking the device context
  68.  * to cough up an nsIFontMetrics object, which contains a list of real font
  69.  * handles, one for each font mentioned in font-family (and for each fallback
  70.  * when we fall off the end of that list).
  71.  *
  72.  * The style system needs to have access to certain metrics, such as the
  73.  * em height (for the CSS "em" unit), and we use the first Western font's
  74.  * metrics for that purpose. The platform-specific implementations are
  75.  * expected to select non-Western fonts that "fit" reasonably well with the
  76.  * Western font that is loaded at Init time.
  77.  */
  78. class nsIFontMetrics : public nsISupports
  79. {
  80. public:
  81.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFONT_METRICS_IID)
  82.  
  83.   /**
  84.    * Initialize the font metrics. Call this after creating the font metrics.
  85.    * Font metrics you get from the font cache do NOT need to be initialized
  86.    *
  87.    * @see nsIDeviceContext#GetMetricsFor()
  88.    */
  89.   NS_IMETHOD  Init(const nsFont& aFont, nsIAtom* aLangGroup,
  90.                    nsIDeviceContext *aContext) = 0;
  91.  
  92.   /**
  93.    * Destroy this font metrics. This breaks the association between
  94.    * the font metrics and the device context.
  95.    */
  96.   NS_IMETHOD  Destroy() = 0;
  97.  
  98.   /**
  99.    * Return the font's xheight property, scaled into app-units.
  100.    */
  101.   NS_IMETHOD  GetXHeight(nscoord& aResult) = 0;
  102.  
  103.   /**
  104.    * Return the font's superscript offset (the distance from the
  105.    * baseline to where a superscript's baseline should be placed). The
  106.    * value returned will be a positive value.
  107.    */
  108.   NS_IMETHOD  GetSuperscriptOffset(nscoord& aResult) = 0;
  109.  
  110.   /**
  111.    * Return the font's subscript offset (the distance from the
  112.    * baseline to where a subscript's baseline should be placed). The
  113.    * value returned will be a positive value.
  114.    */
  115.   NS_IMETHOD  GetSubscriptOffset(nscoord& aResult) = 0;
  116.  
  117.   /**
  118.    * Return the font's strikeout offset (the distance from the 
  119.    * baseline to where a strikeout should be placed) and size
  120.    * Positive values are above the baseline, negative below.
  121.    */
  122.   NS_IMETHOD  GetStrikeout(nscoord& aOffset, nscoord& aSize) = 0;
  123.  
  124.   /**
  125.    * Return the font's underline offset (the distance from the 
  126.    * baseline to where a underline should be placed) and size.
  127.    * Positive values are above the baseline, negative below.
  128.    */
  129.   NS_IMETHOD  GetUnderline(nscoord& aOffset, nscoord& aSize) = 0;
  130.  
  131.   /**
  132.    * Returns the height (in app units) of the font. This is ascent plus descent
  133.    * plus any internal leading
  134.    *
  135.    * This method will be removed once the callers have been moved over to the
  136.    * new GetEmHeight (and possibly GetMaxHeight).
  137.    */
  138.   NS_IMETHOD  GetHeight(nscoord &aHeight) = 0;
  139.  
  140.  
  141. #if defined(XP_WIN) || defined(XP_OS2)
  142. #define FONT_LEADING_APIS_V2 1
  143. #endif 
  144.  
  145. #ifdef FONT_LEADING_APIS_V2
  146.   /**
  147.    * Returns the amount of internal leading (in app units) for the font. This
  148.    * is computed as the "height  - (ascent + descent)"
  149.    */
  150.   NS_IMETHOD  GetInternalLeading(nscoord &aLeading) = 0;
  151.  
  152.   /**
  153.    * Returns the amount of external leading (in app units) as suggested by font
  154.    * vendor. This value is suggested by font vendor to add to normal line-height 
  155.    * beside font height.
  156.    */
  157.   NS_IMETHOD  GetExternalLeading(nscoord &aLeading) = 0;
  158. #else
  159.   /**
  160.    * Returns the amount of internal leading (in app units) for the font. This
  161.    * is computed as the "height  - (ascent + descent)"
  162.    */
  163.   NS_IMETHOD  GetLeading(nscoord &aLeading) = 0;
  164.  
  165.   /**
  166.    * Returns the normal line height (em height + leading).
  167.    */
  168.   NS_IMETHOD  GetNormalLineHeight(nscoord &aHeight) = 0;
  169. #endif /* FONT_LEADING_APIS_V2 */
  170.  
  171.   /**
  172.    * Returns the height (in app units) of the Western font's em square. This is
  173.    * em ascent plus em descent.
  174.    */
  175.   NS_IMETHOD  GetEmHeight(nscoord &aHeight) = 0;
  176.  
  177.   /**
  178.    * Returns, in app units, the ascent part of the Western font's em square.
  179.    */
  180.   NS_IMETHOD  GetEmAscent(nscoord &aAscent) = 0;
  181.  
  182.   /**
  183.    * Returns, in app units, the descent part of the Western font's em square.
  184.    */
  185.   NS_IMETHOD  GetEmDescent(nscoord &aDescent) = 0;
  186.  
  187.   /**
  188.    * Returns the height (in app units) of the Western font's bounding box.
  189.    * This is max ascent plus max descent.
  190.    */
  191.   NS_IMETHOD  GetMaxHeight(nscoord &aHeight) = 0;
  192.  
  193.   /**
  194.    * Returns, in app units, the maximum distance characters in this font extend
  195.    * above the base line.
  196.    */
  197.   NS_IMETHOD  GetMaxAscent(nscoord &aAscent) = 0;
  198.  
  199.   /**
  200.    * Returns, in app units, the maximum distance characters in this font extend
  201.    * below the base line.
  202.    */
  203.   NS_IMETHOD  GetMaxDescent(nscoord &aDescent) = 0;
  204.  
  205.   /**
  206.    * Returns, in app units, the maximum character advance for the font
  207.    */
  208.   NS_IMETHOD  GetMaxAdvance(nscoord &aAdvance) = 0;
  209.  
  210.   /**
  211.    * Returns the font associated with these metrics. The return value
  212.    * is only defined after Init() has been called.
  213.    */
  214.   const nsFont &Font() { return mFont; }
  215.  
  216.   /**
  217.    * Returns the language group associated with these metrics
  218.    */
  219.   NS_IMETHOD  GetLangGroup(nsIAtom** aLangGroup) = 0;
  220.  
  221.   /**
  222.    * Returns the font handle associated with these metrics
  223.    */
  224.   NS_IMETHOD  GetFontHandle(nsFontHandle &aHandle) = 0;
  225.  
  226.   /**
  227.    * Returns the average character width
  228.    */
  229.   NS_IMETHOD  GetAveCharWidth(nscoord& aAveCharWidth) = 0;
  230.  
  231.   /**
  232.    * Returns the often needed width of the space character
  233.    */
  234.   NS_IMETHOD  GetSpaceWidth(nscoord& aSpaceCharWidth) = 0;
  235.  
  236. protected:
  237.  
  238.   nsFont mFont;        // The font for this metrics object.
  239. };
  240.  
  241. #endif /* nsIFontMetrics_h___ */
  242.